package servlets;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.org.apache.xml.internal.utils.SystemIDResolver;

public class PlaceOrderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public PlaceOrderServlet() 
    {
        super();
        // TODO Auto-generated constructor stub
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
    	throws ServletException, IOException 
    {
		doProcessing(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException 
	{
		doProcessing(request, response);
	}
	
	private void doProcessing(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException 
	
	{
		String[] items = {"4", "3", "2"};
		BufferedWriter orderWrite = new BufferedWriter(new FileWriter("C:\\Users\\Stuart.acer\\Desktop\\orderRecord.txt", true));
		for (String s : items)
		{
			orderWrite.write(s);
			orderWrite.newLine();
		}
		orderWrite.close();
		
	}
}